var common = {
	_adclose() {
		//关闭推广
		$('body').on('click', '.igeneralize-ad span', function (e) {
			e.stopPropagation();
			$(this).parent().remove();
		})
	},
	_userinfo_attention() { //用户关注交互效果
		$('body').on('mouseenter', '.userinfo-attention span', function () {
			if ($(this).hasClass('attention-active')) {
				$(this).html('取消关注')
			} else {
				$(this).html('关注')
			}
		}).on('mouseleave', '.userinfo-attention span', function () {
			if ($(this).hasClass('attention-active')) {
				$(this).html('已关注')
			} else {
				$(this).html('关注')
			}
		})
	},
	_bd_share(title, describe, img) { //百度分享  分享内容从类名bdDesc .title中获取
		var bdDesc = encodeURIComponent(title)
		var summary = encodeURIComponent(describe)
		// 分享微博
		var d = window;
		var imgurl = img || $('img')[0].src;
		var wb_appkey = "666245111"; //用于发布微博的来源显示，为空则分享的内容来源会显示来自互联网。(可选，允许为空)1368663223
		$('.share-weibo').click(function (e) {
			window.event ? window.event.cancelBubble = true : e.stopPropagation();
			src = "http://service.weibo.com/share/share.php?url=" + d.location.href + "&appkey=" + wb_appkey + "&title=" + bdDesc + "&pic=" + imgurl; //微博自动抓取图片用这个
			window.open(src + "&title=" + bdDesc, '_blank')
		})
		// QQ分享
		$('#shareQQ').click(function (e) {
			window.event ? window.event.cancelBubble = true : e.stopPropagation();
			src = "https://connect.qq.com/widget/shareqq/index.html?site=数字尾巴&url=" + d.location.href + "&appkey=" + wb_appkey + "&summary=" + summary + "&title=" + bdDesc + "&pics=" + imgurl; //微博自动抓取图片用这个
			window.open(src + "&title=" + bdDesc, '_blank')
		})
		window._bd_share_config = {
			common: {
				bdSnsKey: {
					'tsina': '666245111'
				},
				bdText: bdDesc,
				bdDesc: bdDesc,
				bdUrl: d.location.href,
				bdPic: imgurl
			},
			share: [{
				"bdSize": 16
			}]
		}
		with(document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = '/static/api/js/share.js?cdnversion=' + ~(-new Date() / 36e5)];

	},
	_commentPopUpcancel() { //取消 评论回复弹窗
		$('.comment-pop-up-wrap .cancel').on('click', function () {
			$('.comment-pop-up-wrap').hide();
			$(this).parents('.comment-pop-up-wrap').find('textarea').val('');
			$(this).parents('.comment-pop-up-wrap').find('.filelist').empty();
			// $(this).parents('.comment-pop-up-wrap').find('.addemoji').removeClass('display-block').empty();
		})
		// $('.comment-pop-up-wrap .biaoqing-active').on('click',function(){
		// 	emojiTab($(this).parents('.comment-pop-up-wrap'),$(this).parents('.comment-pop-up-wrap').find('textarea'))
		// })
		// $('.comment-pop-up-wrap .common-uploader .placeholder').on('click',function(){
		// 	$(this).parents('.comment-pop-up-wrap').find('.addemoji').removeClass('display-block').empty();
		// })
	},
	_notAllowedButton(elem) { //禁止操作  当前点击事件的节点必须有单独一个父节点包裹    
		$(elem).parent().append(`<span class="common-not-allowed"></span>`)
		$(elem).parent().css('position', 'relative')
	},
	_notAllowedButtonClose(elem) { //恢复操作
		$(elem).siblings('.common-not-allowed').remove() //恢复操作
		$(elem).parent().css('position', 'static')
	},
	_loadding(elem) { //加载更多组件    
		var str = ` <div class="loadding-wap"><div class="spinner">
        <div class="bounce1"></div>
        <div class="bounce2"></div>
        <div></div>
	</div></div>`;
		if ($('.loadding-wap .spinner').length == 0) {
			return $(elem).append(str);
		}
	},
	_loaddingClose() { //关闭加载按钮
		return $('.loadding-wap').remove();
	},
	_loadding2() {
		str = `<div class="spinner-loading-warp">
        <div class="spinner-loading">
            <div class="dot1"></div>
            <div class="dot2"></div>
        </div>
	</div>`;
		return $('body').append(str);

	},
	_loadding2Close() {
		return $('.spinner-loading-warp').remove();
	},
	_loadding3() {
		str = `<div class="lock-screen"></div>`;
		return $('body').append(str);
	},
	_loadding3Close() {
		return $('.lock-screen').remove();
	},
	_drag(box) { // 拖拽
		var box = document.getElementById(box);
		var bigBox = box.parentNode;
		box.onmousedown = function (e) {

			//组织默认行为
			e = e.preventDefault ? e.preventDefault() : e.returnValue = false;
			var e = e || event;
			var x = e.offsetX;
			var y = e.offsetY;
			document.onmousemove = function (even) {

				//阻止冒泡
				even.stopPropagation ? e.stopPropagation() : even.cancelBubble = true;
				//阻止默认事件
				even = even.preventDefault ? even.preventDefault() : even.returnValue = false;

				var even = even || event;
				var left = even.clientX - x;
				var top = even.clientY - y;
				bigBox.style.margin = '0px';
				//判断边界
				if (left <= 0) {
					left = 0;
				}
				if (left >= document.documentElement.clientWidth - bigBox.offsetWidth) {
					left = document.documentElement.clientWidth - bigBox.offsetWidth
				}
				if (top <= 0) {
					top = 0;
				}
				if (top >= document.documentElement.clientHeight - bigBox.offsetHeight) {
					top = document.documentElement.clientHeight - bigBox.offsetHeight;
				}
				bigBox.style.left = left + 'px';
				bigBox.style.top = top + 'px';
				bigBox.style.margin = '0px';
			}
			document.onmouseup = function () {
				document.onmousemove = null;
				bigBox.onmousedown == null;
			}
		}
	},
	_report(obj_data, e, set_xy) { //举报 set_xy=0 剧中 set_xy 1 随鼠标位置变化
		if (set_xy == 1) {
			e = e || window.event;
			var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; //分别兼容ie和chrome
			var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
			var x = e.pageX || (e.clientX + scrollX); //兼容火狐和其他浏览器
			var y = e.pageY || (e.clientY + scrollY) - 300;
		} else {
			y = 0;
			x = 0;
		}

		var str = `
			<div class="inform-pop-wap maskLayer-colse">
			<div id="maskLayer"></div>
                <div class="inform-pop" style="top:${y}px;left:${x}px;">
                    <ul class="inform-pop-list clearfix">
                        <li class="inform-pop-list-1" data_type="1">垃圾广告内容</li>
                        <li class="inform-pop-list-1" data_type="2">色情、暴力、血腥内容</li>
                        <li class="inform-pop-list-1" data_type="3">歧视、挑衅、辱骂</li>
                        <li class="inform-pop-list-1" data_type="4">政治敏感内容</li>
                        <li class="inform-other-reason">
                            <input type="text" name="" id="informReason" placeholder="其他原因：">
                        </li>
                    </ul>
                    <div class="inform-sub">确定</div>
                </div>
            </div>`;
		$('body').append(str);
		$('#maskLayer').click(function () {
			$('#maskLayer').remove();
			$('.inform-pop-wap').remove();
		})

		$('.inform-pop-wap').on('click', '.inform-pop-list .inform-pop-list-1', function () {
			$(this).toggleClass('active').siblings('.inform-pop-list-1').removeClass('active')
			$(this).siblings('.inform-other-reason').addClass('prompt-msg').find('input').val('')
		})
		$("#informReason").on('focus', function () {
			$('.inform-pop-list .inform-other-reason').removeClass('prompt-msg');
			$('.inform-pop-list .inform-pop-list-1').removeClass('active')
		})
		$('.inform-sub').click(function () {
			var reason;
			if ($('#informReason').val() == '') {
				reason = $('.inform-pop-wap .inform-pop-list .inform-pop-list-1.active').html();
			} else {
				reason = $('#informReason').val();
			}
			if (reason == undefined) {
				// alert('请选择举报内容!');
				messageBox('prompt', '请选择举报内容')
				return false;
			}
			if (disp_confirm('确定举报该内容？') == false) {
				return false;
			} else {
				//获取评论的id
				var aid = obj_data.attr("data_id");
				var article_type = obj_data.attr("data_type");
				var content = $("#informReason").val();
				var objs = $(".inform-pop-wap").find(".inform-pop-list-1");
				var type = 5;
				$.each(objs, function (i, obj) {
					if ($(obj).hasClass('active')) {
						type = $(obj).attr("data_type");
					}
				});

				var module = '';
				if (article_type == 1) {
					module = 'article';
				} else if (article_type == 2) {
					module = 'evaluating';
				} else if (article_type == 3) {
					module = 'evaluating-use';
				} else if (article_type == 4) {
					module = 'inst';
				} else if (article_type == 5) {
					module = 'live';
				} else if (article_type == 10) {
					module = 'sale';
				} else if (article_type == 14) {
					module = 'news';
				} else if (article_type == 17) {
					module = 'activity';
				} else if (article_type == 'user') {
					module = 'user';
				}

				url = '/' + module + '/report';
				if (module == 'user') {
					url = '/' + module + '/report/' + aid;
				}

				//取评论id，评论id不为空则为举报评论
				var comment_id = obj_data.attr("data_comment_id");
				if (comment_id != 'undefined' && $.trim(comment_id)) {
					url = '/' + module + '/comment/report';
				}

				$.ajax({
					url: url,
					async: true,
					type: 'post',
					data: {
						'type': type,
						'content': content,
						'aid': aid,
						'comment_id': comment_id,
					},
					beforeSend: function () {
						common._loadding();
					},
					complete: function () {
						common._loaddingClose();
					},
					success: function (data) {
						if (data.status == 'success') {
							messageBox('prompt', '举报成功');
						} else if (data.status == 'nologin') {
							headerFun._showLogin();
							return;
						} else if (data.status == 'fail') {
							messageBox('prompt', data.message);
						} else {
							messageBox('prompt', '举报成功');
						}
					}
				});

				$('#maskLayer').remove();
				$('.inform-pop-wap').remove();
			}
		})
	},
	_scrolltop() {
		$(window).scroll(function () {
			// console.log($(document).scrollTop())
			if ($(document).scrollTop() >= 263) {
				$('.common-scroll-top').addClass('SHOW')
			} else {
				$('.common-scroll-top').removeClass('SHOW')

			}
		})
		if ($('#f_pst').length > 0) {
			$('.EDIT').show();
		} else {
			$('.EDIT').hide();
		}
		$('.common-scroll-top .TOP').click(function () {
			$('body,html').animate({
				scrollTop: 0
			}, 1000);

		})
		var flag = true //设置标识。防止出现跑马灯  
		$('.common-scroll-top .EDIT').click(function () {
			flag = false
			var top = $('#f_pst').offset().top; //获取每个banner到顶部的距离  
			jQuery("html,body").stop(true).animate({
				"scrollTop": top
			}, 1000, function () {
				flag = true
			})
		})

	}
}


// 图片轮播插件可以传入对象
function Viewer(ID, obj) {
	$(ID).lightGallery({
		mode: "lg-slide",
		cssEasing: "ease",
		easing: "linear",
		speed: 300,
		height: "100%",
		width: "100%",
		addClass: "",
		startClass: "lg-start-zoom",
		backdropDuration: 150,
		hideBarsDelay: 6000,
		useLeft: false,
		closable: true,
		loop: false,
		escKey: true,
		keyPress: true,
		controls: true,
		slideEndAnimatoin: true,
		hideControlOnEnd: false,
		mousewheel: true,
		getCaptionFromTitleOrAlt: true,
		appendSubHtmlTo: ".lg-sub-html",
		subHtmlSelectorRelative: false,
		preload: 1,
		showAfterLoad: true,
		selector: "",
		selectWithin: "",
		nextHtml: "",
		prevHtml: "",
		index: false,
		iframeMaxWidth: "100%",
		download: true,
		counter: true,
		appendCounterTo: ".lg-toolbar",
		swipeThreshold: 50,
		enableSwipe: true,
		enableDrag: true,
		dynamic: false,
		dynamicEl: [],
		galleryId: 1
	});
}
// // **********************查看原图 start**********************
function artwork(src) {
	// $('html').append(`<div class="artwork"><img src="${src}" alt=""></div>`)
	// $('.artwork').click(function(){
	// 	$(this).hide();
	// })
	window.open(src, '_blank')
}
// // **********************查看原图 end**********************



// **********************表情的tab切换/添加表情包 start****************
/**
 * 
 * @param {*} parentId  父级id
 * @param {*} textareaId 内容id
 * 可查看comment.js中的使用方法
 */

function emojiTab(parentId, textareaId) {
	var textarea = $(textareaId);
	var parent = $(parentId);
	parent.find('.addemoji').toggleClass('display-block');
	addEmojiList(parent);
	parent.find('.emoji-title li').click(function (e) {
		common_stopBubble(e);
		common_stopDefault(e);
		$(this).addClass('active').siblings().removeClass('active')
		$(this).parent().siblings('.emoji-list').find('.emoji-list-1').eq($(this).index()).show().siblings('.emoji-list .emoji-list-1').hide()
	})
	// 添加表情包
	$(parent).find('.emoji-sub').unbind('click').click(function (e) {
		common_stopBubble(e);
		common_stopDefault(e);
		var str = textarea.val(); //先获取原有的值
		if (str) {
			textarea.val(str + ` ${$(this).children().attr('data-content')} `);
		} else {
			textarea.val(` ${$(this).children().attr('data-content')} `);
		}
		// commonAutoHeightTextarea();
	})
}

function addEmojiList(elem) {
	//获取表情的数据
	var smile_datas = getSmile();
	if (!smile_datas) {
		messageBox('prompt', '获取表情数据异常');
		return;
	}

	var smile_ul = '';
	$.each(smile_datas, function (i, smile_data) {
		if (i == 0) {
			smile_ul += `<ul class="emoji-list-1" style="display:block">`;
			$.each(smile_data, function (j, smile) {
				smile_ul += `<li class="emoji-sub"> <img src="${smile.smile_img}" alt="" data-content="${smile.smile_text}"></li>`;
			});
			smile_ul += `</ul>`;
		} else {
			smile_ul += `<ul class="emoji-list-1">`;
			$.each(smile_data, function (j, smile) {
				smile_ul += `<li class="emoji-sub"> <img src="${smile.smile_img}" alt="" data-content="${smile.smile_text}"></li>`;
			});
			smile_ul += `</ul>`;
		}
	});

	var html = `<div class="arrow-icon"></div>
	<ul class="emoji-title">
		<li class="active">小鲸鱼</li>
		<li>大鲸鱼</li>
		<li>emoji</li>
	</ul>
	<div class="emoji-list">`;

	html = html + smile_ul + `</div>`;

	elem.find('.addemoji').append(html);
	if (!elem.find('.addemoji').hasClass('display-block')) {
		elem.find('.addemoji').empty();
	}

}

function commonReplybiaoqing() {
	$('body').on('click', '.comment-pop-up-reply .biaoqing-active', function () {
		emojiTab($(this).parents('.comment-pop-up-reply'), $(this).parents('.comment-pop-up-reply').find('textarea'))
	})
}

// **********************表情的tab切换/添加表情包 end****************
//confirm 弹窗
function disp_confirm(data) {
	var r = confirm(data)
	if (r == true) {
		return true;
	} else {
		return false;
	}
}


//  ************************瀑布流*start***********************
var floor = function (elem) {

	var boxArr = $(elem).find('.item'),
		num = Math.floor(document.body.clientWidth / boxArr.eq(0).outerWidth(true)),
		//以inner内盒实际宽度为准
		num = Math.floor(1220 / boxArr.eq(0).outerWidth(true)),
		columnHeightArr = [];
	columnHeightArr.length = num;
	boxArr.each(function (index, item) {
		if (index < num) {
			columnHeightArr[index] = $(item).position().top + $(item).outerHeight(true);
		} else {
			var minHeight = Math.min.apply(null, columnHeightArr),
				minHeightIndex = $.inArray(minHeight, columnHeightArr);
			// console.log(minHeight)
			$(item).css({
				position: 'absolute',
				top: minHeight,
				left: boxArr.eq(minHeightIndex).position().left
			});
			columnHeightArr[minHeightIndex] += $(item).outerHeight(true);
		}
	});

	//加载更多的位置
	var endHeight = Math.max.apply(null, columnHeightArr); //最后一行的最大值
	//  var loadingArr = [];
	// $('.fixed-item').each(function (index) {
	//     loadingArr[index] = $('.fixed-item').eq(index).outerHeight()
	// });
	// var loadingHeight = Math.max.apply(null, loadingArr);  //fixed-item中的最大值

	// $('.floor-footer').css({
	//     'margin-top': endHeight -500
	// });
	//盒子高度
	if (isNaN(endHeight)) {
		$(elem).css({
			'height': 'auto'
		});
	} else {
		$(elem).css({
			'height': endHeight
		});
	}

}
////  ************************瀑布流end***********************


/**
 *  通过缩放属性适应各个宽度的平板 start
 */
// var s=document.body.clientWidth;
// var scale = s/1250;
// var meta=document.getElementsByTagName('meta');
// if(s < 1250 && s > 700){
//     console.log('12')
//     meta[1].setAttribute('content',"width=device-width, initial-scale=" + scale + ", minimum-scale=" + scale + ", maximum-scale=2.0");
// }
// 通过缩放属性适应各个宽度的平板 end




// **********************阻止冒泡和默认行为 start**********************

function common_stopBubble(e) {
	//如果提供了事件对象，则这是一个非IE浏览器 
	if (e && e.stopPropagation)
		//因此它支持W3C的stopPropagation()方法 
		e.stopPropagation();
	else
		//否则，我们需要使用IE的方式来取消事件冒泡 
		window.event.cancelBubble = true;
}

function common_stopDefault(e) {
	//阻止默认浏览器动作(W3C) 
	if (e && e.preventDefault)
		e.preventDefault();
	//IE中阻止函数器默认动作的方式 
	else
		window.event.returnValue = false;
	return false;
}
// **********************阻止冒泡和默认行为 end**********************

$('body').on('mouseenter', '.placeholder,.webuploader-container', function () {
	$('.icon-all_edit_photo').css('color', '#506a8a')
})
$('body').on('mouseleave', '.placeholder,.webuploader-container', function () {
	$('.icon-all_edit_photo').css('color', '#999')
});

/**
 * *********************查看用户卡片信息  start*********************
 * // .author-avator .own-img  用户头像查看卡片信息需要包含此类名
 */
function showUserInfoPopUp(elem, head_obj) {
	// <!-- 用户信息 -->
	jqThis = $(elem),
		objRect = jqThis[0].getBoundingClientRect(),
		winTop = $(window).scrollTop(),
		winLeft = $(window).scrollLeft();
	var jqLeft = objRect.x + winLeft,
		jqTop = objRect.y + objRect.height + winTop;

	var head_div = `<div class="userinfo-pop-up-warp user-info-card" style="top:${jqTop + 15}px;left:${jqLeft - 15}px"><div class="userinfo-pop-up border-radius">
	<div class="arrow-icon"></div>
	<div class="userinfo-pop-up-1">
		<a href="/user?uid=${head_obj.encode_uid}" class="userinfo-photo radius-50 avatar"><img class="img-cover" src="${head_obj.avatar_path}" alt=""></a>
		<div  class="userinfo-pop-up-name"><span>${head_obj.user_name}</span><p class="p-omit">${head_obj.introduce}</p></div>
	</div>
	<div class="userinfo-pop-up-2">`;
	if (!!$.trim(head_obj.user_authentication_title)) {
		head_div += `<p><span class="block radius-50 "><i class="icon-Dgtlex-dgtlexicon-avatar block"></i></span>${head_obj.user_authentication_title}</p>`;
	}
	head_div += `<p><i class="icon-all_like_on_new"></i>内容获得${head_obj.likes}次赞 ·${head_obj.push}次精选</p>
		<ul>
			<li><span>Ta的关注</span><p>${head_obj.focus}</p></li>
			<li><span>Ta的粉丝</span><p>${head_obj.fans}</p></li>
		</ul>
	</div>
	<div class="userinfo-pop-up-3">`;

	if (head_obj.is_attention == 1) {
		head_div += `<div class="icon-more userinfo-attention attention-hover attention-active" data_encode_uid="${head_obj.encode_uid}" data_is_attention="${head_obj.is_attention}"><span>已关注</span></div>`;
	} else {
		head_div += `<div class="icon-more userinfo-attention attention-hover" data_encode_uid="${head_obj.encode_uid}" data_is_attention="${head_obj.is_attention}"><span>关注</span></div>`;
	}

	head_div += `<div class="icon-more2 userinfo-letter" data_encode_uid="${head_obj.encode_uid}"><span>私信</span></div>
	</div>
</div></div>`;
	$('body').append(head_div);
	jqThis.addClass('showInfoCard');

	$('.user-info-card .userinfo-pop-up').on('click', ' .userinfo-attention', function () {
		var data_is_attention = $(this).attr("data_is_attention");
		var data_encode_uid = $(this).attr("data_encode_uid");
		if (data_is_attention == 1) {
			var url = "/user/unfriend/" + data_encode_uid;
		} else {
			var url = "/user/attention/" + data_encode_uid;
		}

		var this_obj = $(this);
		$.ajax({
			url: url,
			async: true,
			beforeSend: function () {},
			complete: function () {},
			success: function (data) {
				if (data.status == 'success') {
					if (data_is_attention == 1) {
						messageBox('prompt', '取消关注成功');
						this_obj.removeClass('attention-active');
						this_obj.attr('data_is_attention', 0);
						this_obj.html('<span>关注</span>');
					} else {
						messageBox('prompt', '关注成功');
						this_obj.children().addClass('attention-active');
						this_obj.attr('data_is_attention', 1);
						this_obj.html('<span>已关注</span>');
					}
				} else if (data.status == 'nologin') {
					headerFun._showLogin();
					return;
				} else if (data.status == 'fail') {
					messageBox('prompt', data.message);
				} else {
					messageBox('prompt', '系统繁忙,关注失败');
				}
			},
		});

	})

	$('.user-info-card .userinfo-pop-up').on('click', ' .userinfo-letter', function () {
		//header.php添加登录的uid判断是否登录
		var head_decode_uid = $("#head_encode_uid").val();
		if (head_decode_uid == '0') {
			headerFun._showLogin();
			return;
		}

		var encode_uid = $(this).attr("data_encode_uid");
		window.location.href = '/message/letterDialog/' + encode_uid;
	})
}

function hideUserInfoPopUp(el) {
	var that = $(el);
	if (that.hasClass('showInfoCard')) {
		var infoCard = $('body').find('.user-info-card');
		that.removeClass('showInfoCard');
		infoCard.remove();
	}
}
var cardTimer, Timer_1;

$(document).on('mouseenter', '.author-avator', function () {
	//获取用户的信息
	var encode_uid = $(this).attr("data_encode_uid");
	var head_info = getUserHeadInfo(encode_uid);

	if (!head_info) {
		messageBox('prompt', '获取信息失败');
		return;
	} else if (head_info == 'nologin') {
		return;
	}

	clearTimeout(cardTimer);
	cardTimer = setTimeout(() => {
		showUserInfoPopUp($(this), head_info);
	}, 500)

}).on('mouseleave', '.author-avator', function () {
	clearTimeout(cardTimer);
	Timer_1 = setTimeout(() => {
		hideUserInfoPopUp($(this))
	}, 300)
})

$(document).on('mouseenter', '.user-info-card', function () {
	clearTimeout(Timer_1)
}).on('mouseleave', '.user-info-card', function () {
	$(this).remove();
})

function getUserHeadInfo(encode_uid) {
	var head_data = false;
	var url = '/user/getUserHeadInfo/' + encode_uid;
	$.ajax({
		url: url,
		async: false,
		type: 'get',
		beforeSend: function () {
			common._loadding();
		},
		complete: function () {
			common._loaddingClose();
		},
		success: function (data) {
			if (data.status == 'success') {
				head_data = {
					'avatar_path': data.data.user_info.avatar_path,
					'user_name': data.data.user_info.username,
					'user_authentication_title': data.data.user_info.user_authentication_title,
					'fans': data.data.user_info.fans,
					'focus': data.data.user_info.focus,
					'is_attention': data.data.is_attention,
					'encode_uid': data.data.encode_uid,
					'introduce': data.data.user_info.introduce,
					'likes': data.data.user_info.likes,
					'push': data.data.user_info.push,
				};
			} else if (data.status == 'fail') {
				head_data = false;
			} else {
				head_data = false;
			}
		},
	});

	return head_data;
}



/**
 * ***************************查看用户卡片信息  end**************************************
 */

// 关注按钮效果
/**
 * 包含类名 userinfo-attention,.attention-hover 已关注的需要添加attention-active 此功能才有效
 */
// $(document).on('mouseenter','.userinfo-attention,.attention-hover',function(){
// if($(this).hasClass('attention-active')){
// 	$(this).children('span').html('取消关注')
// }else{
// 	$(this).children('span').html('关注')
// }
// }).on('mouseleave','.userinfo-attention,.attention-hover',function(){
// if($(this).hasClass('attention-active')){
// 	$(this).children('span').html('已关注')
// }else{
// $(this).children('span').html('关注')
// }

// })


// function UseCommentCards(elem){
// 	$(body).append(``)
// } 


// *************************公共回复样式 start*************************
function commonReply(elem) {
	var aid = $(elem).attr("data_aid");
	var comment_id = $(elem).attr("data_comment_id");
	var user_name = $(elem).attr("data_user_name");
	var item_id = $(elem).attr("data_item_id");
	var str = `   <div class="comment-pop-up-reply" style=" display: block;">
	<form id="common_comment_reply_form">
	    <input type="hidden" name="aid" value="${aid}">
	    <input type="hidden" name="reply_id" value="${comment_id}">
	    <input type="hidden" name="item_id" value="${item_id}">
		<div class="comment-pop-up-reply-1">
			<textarea class="reply-textarea" name="content" placeholder="回复 : ${user_name}"></textarea>
		</div>
		<!-- 图片上传 start -->
		<div class="fileList-warp">
		<div id="fileList" class="uploader-list"></div>
		</div>
		<div id="filePicker"><p class="icon-editor_plus_photo_icon"></p></div>
		<!-- 图片上传 end -->
		<div class="comment-pop-up-reply-2 clearfix">
			<div class="comment-pop-up-reply-l l">
				<div class="l"><i class="icon-Dgtlex-dgtlexicon-biaoqing biaoqing-active"></i></div>
				<div class="l"><i class="icon-all_edit_photo pic-active"></i></div>
			</div>
			<div class="comment-pop-up-reply-r r"><span class="reply-cancel">取消</span><span class="put-comment">评论</span></div>
		</div>
	</form>
		<div class="add-lable addemoji emoji"></div> 
	</div>`;
	elem.parent().parent().append(str)
}

function commonReply2(elem, touid, touser_name) {
	var data_aid = $(elem).attr("data_aid");
	var data_comment_id = $(elem).attr("data_comment_id");
	var data_module = $(elem).attr("data_module");
	var str = `   <div class="comment-pop-up-reply" style=" display: block;">
	<form id="reply_form">
		<div class="comment-pop-up-reply-1">
			<textarea name="content" placeholder="回复:${touser_name}"></textarea>
		</div>
		<div class="comment-pop-up-reply-2 clearfix">
			<div class="comment-pop-up-reply-r r"><span class="reply-cancel">取消</span><span data_touid="${touid}" data_aid="${data_aid}" data_comment_id="${data_comment_id}" data_module="${data_module}" data_tousername="${touser_name}" class="put-comment">发送</span></div>
		</div>
	</form>
	</div>`;
	elem.append(str)
	$('.comment-pop-up-reply .put-comment').click(function () {

		$('.send-message-pop-up-warp .send-message-sub').click(function () {
			if ($('#messageName').val() == '') {
				$('#messageName').focus();
				return;
			}
			if ($('#privateMessage').val() == '') {
				$('#privateMessage').focus();
				return;
			}
			callBack($("#commonReply2").serialize());

		})
	})
}

function commonReplyHide() {
	$('.comment-pop-up-reply').remove();
}

/**
 *取消回复 
 * @param {elem}  该为点击出现回复元素
 */
function commonreplyCancel(elem) {
	$("body").on("click", ".reply-cancel", function (event) {
		var target = $(event.target);
		target.parents('.comment-pop-up-reply').parent().parent().find(elem).removeClass('reply-active');
		commonReplyHide()
	})
}

/**
 *取消回复 
 * @param {parentselem} 父节点 
 * @param {elem}  该为点击出现回复元素
 */
function commonreplyCancel2(parentselem, elem) {
	$("body").on("click", ".reply-cancel", function (event) {
		var target = $(event.target);
		target.parents(parentselem).find(elem).removeClass('reply-active');
		commonReplyHide()
	})
}
// ********************************公共回复样式 end***************************

function quotePopUp(obj, callBack) {
	var user_name = obj.attr('data_user_name');
	str = `<!-- 评论弹框 start -->
    <div class="comment-pop-up-wrap" >
        <div class="comment-pop-up" style="position: absolute;">
                <div class="pop-up-drag" id="drag"><i class="comment-close icon-in_clear_icon"></i></div>
                <form id="reply_form">
                    <div class="comment-pop-up-1">
                        <textarea name="content" id="popUpText" cols="30" rows="10" placeholder="引用${user_name}的评论"></textarea>
                    </div>
                    <!-- 图片上传 start -->
                    <div class="uploder-container uploader-idle-edit common-uploader">										      		
                        <div id="fileList" class="cxuploder uploader-list">
                            <div class="queueList">
                                <div class="placeholder">
                                    <div id="filePicker"></div>
                                </div>
                            </div>
                        </div>
					</div>
                    <!-- 图片上传 end -->
                    <div class="comment-pop-up-3 clearfix">
                        <div class="comment-pop-up-3-l l">
                            <div class="l"><i class="icon-Dgtlex-dgtlexicon-biaoqing biaoqing-active"></i></div>
                            <div class="l"><i class="icon-Dgtlex-dgtlexicon-picture-empty pic-active"></i></div>
                        </div>
                        <div class="comment-pop-up-3-r r"><span class="cancel">取消</span><span class="put-comment">评论</span></div>
                    </div>
                </form>
                    <!-- 表情包 -->
                    <div class="add-lable emoji addemoji"></div> 
                </div>
    </div>
	<!-- 评论弹框 end -->`
	commonReplyHide();
	if ($('.comment-pop-up-wrap').length == 0) {
		$('body').append(str);
		$('.comment-pop-up-wrap').show();

	} else {
		$('.comment-pop-up-wrap').show();

	}

	var id = obj.attr("data_comment_id");
	var aid = obj.attr("data_aid");
	$("#reply_form").append("<input type='hidden' name='aid' value='" + aid + "'>");
	$("#reply_form").append("<input type='hidden' name='reply_id' value='" + id + "'>");
	$("#reply_form").append("<input type='hidden' name='comment_type' value='quote'>");

	$('.comment-pop-up-wrap .biaoqing-active').unbind('click').click(function () {
		emojiTab('.comment-pop-up-wrap', '#popUpText')
	})
	$('.comment-pop-up-wrap .cancel').click(function () {
		quotePopUpClose();
	})

	$('.comment-pop-up-wrap .put-comment').click(function () {
		if ($('#popUpText').val() == '') {
			messageBox('warning', '评论内容不能为空！')
			return
		}

		var module = $("#module").val();
		var url = module + '/comment/reply';
		$.ajax({
			url: url,
			async: true,
			type: 'post',
			data: $("#reply_form").serialize(),
			beforeSend: function () {
				common._loadding();
			},
			complete: function () {
				common._loaddingClose();
			},
			success: function (data) {
				if (data.status == 'success') {
					window.location.reload();
				} else if (data.status == 'nologin') {
					headerFun._showLogin();
				} else if (data.status == 'fail') {
					alert(data.message);
				} else {
					alert('系统繁忙');
				}
			}
		});
	})
}

function quotePopUpClose() {
	$('.comment-pop-up-wrap').remove();
}


// ********************************公共回复样式 end***************************
function commonAutoHeightTextarea() {
	$("textarea").autoHeightTextarea({
		// minRows: 3,
		// maxRows: 3
	});
}

//图片上传实例化
var module = $("#module").val();

function commonEditUploader() { //图片上传实例化
	var $ = jQuery,
		$list = $('#fileList'),
		// 优化retina, 在retina下这个值是2
		ratio = 1 || 1,

		// 缩略图大小
		thumbnailWidth = 100 * ratio,
		thumbnailHeight = 100 * ratio,

		// 初始化Web Uploader
		uploader = WebUploader.create({
			// 选完文件后，是否自动上传。
			auto: true,
			// swf文件路径
			swf: '/content/plugins/webuploader/Uploader.swf',
			fileNumLimit: 1,
			// 文件接收服务端。
			server: '/upload/uploadImg?module=' + module, //上传地址
			// 选择文件的按钮。可选。
			// 内部根据当前运行是创建，可能是input元素，也可能是flash.
			pick: '#filePicker',
			formData: {
				destDir: "user"
			},
			compress: false, //不启用压缩
			resize: false,
			// 只允许选择图片文件。
			accept: {
				title: 'Images',
				extensions: 'gif,jpg,jpeg,bmp,png',
				mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png' //修改这行
			}
		});

	// 当有文件添加进来的时候
	uploader.on('fileQueued', function (file) {
		var $list = $('#fileList');
		var $li = $(
				'<div id="' + file.id + '" class="file-item thumbnail">' +
				'<p class="imgWrap"><img></p>' +
				'<div class="info">' + file.name + '</div>' +
				'</div>'
			),
			$img = $li.find('img');
		var $btns = $('<div class="file-panel">' +
			'<span class="cancel" ><i class="icon-Dgtlex-dgtlexicon-wrong"></i></span>').appendTo($li);

		$li.on('mouseenter', function () {
			$btns.stop().animate({
				height: 30
			});
		});
		$li.on('mouseleave', function () {
			$btns.stop().animate({
				height: 0
			});
		});
		// $list为容器jQuery实例
		$list.append($li);
		$btns.on('click', 'span', function () {
			var index = $(this).index();
			switch (index) {
				case 0:
					uploader.removeFile(file);
					removeFile(file);
					return;
			}
		});
		// 创建缩略图
		// 如果为非图片文件，可以不用调用此方法。
		// thumbnailWidth x thumbnailHeight 为 100 x 100
		uploader.makeThumb(file, function (error, src) {
			if (error) {
				$img.replaceWith('<span>不能预览</span>');
				return;
			}
			$img.attr('src', src);
		}, thumbnailWidth, thumbnailHeight);
	});
	uploader.on('beforeFileQueued', function (file) {
		var fileNumLimit = uploader.options.fileNumLimit;
		if ($('#fileList .file-item').length == fileNumLimit) {
			messageBox('prompt', '评论只能上传一张图片！');
			return false
		}
		//限制个数
		var completeNum = uploader.getFiles("complete").length;
		//    if (fileNumLimit == completeNum){
		//        $.fn.modalAlert("最大上传"+fileNumLimit+"个文件，不能超过","error");
		//    }
		/*console.log("上传限制"+);
		console.log("上传成功"+);*/
	});
	// 文件上传过程中创建进度条实时显示。
	uploader.on('uploadProgress', function (file, percentage) {
		var $li = $('#' + file.id),
			$percent = $li.find('.progress span');
		// 避免重复创建
		if (!$percent.length) {
			$percent = $('<p class="progress"><span></span></p>')
				.appendTo($li)
				.find('span');
		}
		$percent.css('width', percentage * 100 + '%');
	});
	// 文件上传成功，给item添加成功class, 用样式标记上传成功。
	uploader.on('uploadSuccess', function (file, response) {
		if (response.status == 'nologin') {
			$("#" + file.id).remove();
			alert('未登录');
		} else if (response.status == 'fail') {
			$("#" + file.id).remove();
			alert(response.message);
		} else if (response.status == 'success') {
			//获取img的长度
			var length = $("input[name^='upload_img']").length;
			var img_no = length;
			var html = "<input type='hidden' name='upload_img[" + img_no + "]' value='" + response.data.id + "'>";
			$("#" + file.id).append($(html));
		} else {
			$("#" + file.id).remove();
			alert('系统繁忙，图片上传失败');
		}
	});

	// 文件上传失败，显示上传出错。
	uploader.on('uploadError', function (file) {
		//alert("失败");
		var $li = $('#' + file.id),
			$error = $li.find('div.error');
		// 避免重复创建
		if (!$error.length) {
			$error = $('<div class="error"></div>').appendTo($li);
		}
		$error.text('上传失败');
		var fileStatusnum = uploader.getStats();
		// layer.msg("上传失败" + fileStatusnum.uploadFailNum + "个文件", {icon: 1, time: 1000});
	});


	uploader.on('uploadBeforeSend', function (object, data, header) {
		common._loadding2();
	});

	// 完成上传完了，成功或者失败，先删除进度条。
	uploader.on('uploadComplete', function (file) {
		common._loadding2Close();
		$('#' + file.id).find('.progress').remove();
	});

	// 负责view的销毁
	function removeFile(file) {
		var $li = $('#' + file.id);
		$li.off().find('.file-panel').off().end().remove();
	}
}

//图片描述处理
function imgAltshow() { //编辑器设置属性的方法
	$('.imgAltshow img').each(function (key, value) {
		if ($(value).attr('src') == '') {
			$(this).attr('alt', '')
		} else if ($(value).attr('alt') && $(value).attr('src') && $(value).after()[0].nodeName != 'FIGCAPTION') {
			$(value).after('<figcaption class="alt-img" style="max-width:' + $(value).css("max-width") + '">' + $(value).attr('alt') + '</figcaption>')
		}
	})
	$(".imgAltshow img").error(function () {
		$(this).attr('alt', '')
		if ($(this).parent('figure')) $(this).parent('figure').find('figcaption').remove();
		else(this).parents('figure').find('figcaption').remove();
	});

}


//   ************************消息弹窗系统 start**********************
function messageBox(type, data) {
	var str;
	switch (type) {
		case 'prompt':
			str = `<div class="message-box messageInfo prompt">
		<i class="message-icon radius-50">i</i>
		<span>${data}</span>
		</div> `
			break;
		case 'warning':
			str = ` <div class="message-box messageInfo warning">
				<div class="message-icon radius-50"><i class="icon-Dgtlex-dgtlexicon-wrong"></i></div>
				<span>${data}</span>
		</div>`
			break;
		case 'success':
			str = `<div class="message-box messageInfo success">
				<div class="message-icon radius-50"><i class="icon-all_done"></i></div>
				<span>${data}</span>
		</div>`
			break;
		default:
	}
	if ($('body .message-box').length == 0) {
		$('body').append(str);
	}
	setTimeout(function () {
		$('.messageInfo').remove();
	}, 1200)
}

function messageBoxConfirm1(data1, data2, yesCallBack, noCallBack) {
	str = ` <div class="message-confirm-warp" >
		<div class="message-confirm">
				<p><i class="message-icon radius-50">i</i>${data1}</p>
				 <span>${data2}</span>
				 <div class="message-confirm-list">
					 <div class="icon-more confirm-ok"><span>确认</span></div>
					 <div class="confirm-cancel"><span>取消</span></div>
				 </div>
			</div>
		   
		</div>`;
	if ($('body .message-confirm-warp').length == 0) {
		$('body').append(str);
	}
	$('body .message-confirm-warp .confirm-ok').unbind('click').click(function () {
		yesCallBack();
	})
	$('body .message-confirm-warp .confirm-cancel').unbind('click').click(function () {
		noCallBack();
		messageBoxConfirmClose1();
	})
}

function messageBoxConfirmClose1() {
	$('body .message-confirm-warp').remove();
}


function messageBoxConfirm2(elem, yesCallBack, noCallBack) {
	jqThis = $(elem),
		objRect = jqThis[0].getBoundingClientRect(),
		winTop = $(window).scrollTop(),
		winLeft = $(window).scrollLeft();
	var jqLeft = objRect.x + winLeft,
		jqTop = objRect.y + objRect.height + winTop;
	str = `<div class="message-delete delete-box2" style="top:${jqTop - 160}px;left:${jqLeft - 120}px">
	<p>你确定要删除这条评论？</p>
		<div class="message-confirm-list">
						<div class="icon-more confirm-ok"><span>确认</span></div>
						<div class="confirm-cancel"><span>取消</span></div>
					</div>
					<div class="triangle-top-icon"></div>
</div>`;

	if ($('.delete-box2').length == 0) {
		$('body').append(str);
	} else {
		$('.delete-box2').css({
			top: jqTop - 160,
			left: jqLeft - 120
		})
	}
	$('body .delete-box2 .confirm-ok').unbind('click').click(function () {
		yesCallBack();
	})
	$('body .delete-box2 .confirm-cancel').unbind('click').click(function () {
		noCallBack();
		messageBoxConfirmClose2();
	})
}

function messageBoxConfirmClose2() {
	$('body .delete-box2').remove();
}


function messageBoxConfirm3(elem, yesCallBack, noCallBack) {
	jqThis = $(elem),
		objRect = jqThis[0].getBoundingClientRect(),
		winTop = $(window).scrollTop(),
		winLeft = $(window).scrollLeft();
	var jqLeft = objRect.x + winLeft,
		jqTop = objRect.y + objRect.height + winTop;
	if (jqTop <= 330) {
		jqTop = jqTop - 80;
	} else {
		jqTop = jqTop - 280
	}
	if (jqLeft <= 500) {
		jqLeft = jqLeft - 40;
	} else {
		jqLeft = jqLeft - 110
	}
	str = `<div class="message-delete delete-box1" style="top:${jqTop}px;left:${jqLeft}px" >
	<div class="triangle-bottom-icon"></div>
	<div class="choose-classify-1">
				<div class="choose-classify-1-control"><span>违反「社区 准则」</span><i class="icon-Dgtlex-dgtlexicon-arrow-button-up"></i><i class="icon-Dgtlex-dgtlexicon-arrow-button-down"></i></div>
				<ul class="choose-classify-1-content">
					<li>重复发帖</li>
					<li>无意义灌水内容</li>
					<li>人身攻击、侮骂他人</li>
					<li>发布违规广告、推广</li>
					<li>敏感内容不允许发布</li>
					<li>违反「社区准则」</li>
					<li>自定义</li>
				</ul>
			</div>
			<div class="message-delete-reason">
				<textarea name="" id="deleteReason"  placeholder="删除原因">违反「社区 准则」</textarea>
			</div>
			<div class="message-delete-reason-1">
				  <span> <input type="checkbox" value="2">通知作者</span>
				</div>
		<div class="message-confirm-list">
						<div class="icon-more confirm-ok"><span>确认</span></div>
						<div class="confirm-cancel"><span>取消</span></div>
					</div>
					<div class="triangle-top-icon"></div>
</div>`;
	if ($('.delete-box1').length == 0) {
		$('body').append(str);
	} else {
		$('.delete-box1').css({
			top: jqTop,
			left: jqLeft
		})
	}
	if (jqTop <= 250) {
		$('.triangle-bottom-icon').show();
		$('.triangle-top-icon').hide();
	} else {
		$('.triangle-top-icon').show();
		$('.triangle-bottom-icon').hide();
	}
	var msg = $('.message-delete-reason text').html();
	$('body .delete-box1 .confirm-ok').unbind('click').click(function () {
		var is_notice = $('.message-delete-reason-1 input').is(":checked");
		yesCallBack(msg, is_notice);
	})
	$('body .delete-box1 .confirm-cancel').unbind('click').click(function () {
		noCallBack();
		messageBoxConfirmClose3();
	})

	$('.message-delete .choose-classify-1-control').unbind('click').click(function () {
		$(this).siblings('.choose-classify-1-content').slideToggle(300);
	})
	$('.message-delete .choose-classify-1-content li').unbind('click').click(function () {
		$('.message-delete  .choose-classify-1-control span').html($(this).html());
		msg = $(this).html();
		$('.message-delete #deleteReason').val($(this).html())
		$('.message-delete .choose-classify-1-content').slideUp(300);
	})

	$('.message-delete  #deleteReason').bind('input propertychange', function () {
		msg = $(this).val();
	});
}

function messageBoxConfirmClose3() {
	$('body .delete-box1').remove();
}
$(document.body).click(function () {
	messageBoxConfirmClose3();
});
//   ************************消息弹窗系统 end**********************

//********************************私信弹窗start*******************

function privateLetterPopUp(val, callBack) {
	var str = `<div class="send-message-pop-up-warp">
	<div class="send-message-pop-up">
		<p class="send-message-pop-up-title">发私信</p> 
		<div class="close"><i class="icon-all_off"></i></div>
		<div class="send-message-pop-up-contetn">
			<form id="sendMessage">
				<div class="send-message-pop-up-user">
					<span>发生给：</span>
					<div>
						<input type="text" name="user_name" id="messageName" placeholder="搜索用户">
					</div>
					<ul style="display:none;">
					</ul>
				</div>
				<div class="send-message-pop-up-textarea">
					<span>内容</span>
					<textarea name="content" id="privateMessage" cols="30" rows="10"></textarea>
				</div>
			</form>
		</div>
		<div class="send-message-pop-up-footer">
			<div class="icon-more"><span class="send-message-sub">发送</span></div>
		</div>
	</div>
</div>`
	if ($('.send-message-pop-up-warp').length == 0) {
		$('body').append(str);
		$('.send-message-pop-up-warp').show();
	} else {
		$('.send-message-pop-up-warp').show();
	}
	// 关闭发私信弹窗
	$('.send-message-pop-up-warp .send-message-pop-up .close').click(function () {
		$('.send-message-pop-up-warp').hide();
		$('#messageName').val('');
		$('#privateMessage').val('');
	})
	// 删除私信弹窗
	$('.send-message-pop-up-footer .detele').click(function () {
		$('#messageName').val('');
		$('#privateMessage').val('');
	})

	$('.send-message-pop-up-warp').on('click', '.send-message-pop-up-user ul li', function () {
		$('#messageName').val($(this).html())
		$('.send-message-pop-up-warp .send-message-pop-up-user ul').hide()
	})

	$('#messageName').focus(function () {
		$('.send-message-pop-up-warp .send-message-pop-up-user ul').show()
	});

	$('.send-message-pop-up-warp .send-message-sub').click(function () {
		if ($('#messageName').val() == '') {
			$('#messageName').focus();
			return;
		}
		if ($('#privateMessage').val() == '') {
			$('#privateMessage').focus();
			return;
		}

		callBack($("#sendMessage").serialize());
	})

}

function privateLetterPopUpClose() {
	$('.send-message-pop-up-warp').hide()
}

//********************************私信弹窗end**********************
//**********************转发组件stret**********************
function forwardBox(obj_data, callBack) {
	var aid = $(obj_data).attr("data_aid");
	var type = $(obj_data).attr("data_type");
	var data_title = $(obj_data).attr("data_title");
	var data_cover = $(obj_data).attr("data_cover");
	var user_name = $(obj_data).attr("data_user_name");
	str = `<div class="transpond-pop-up-warp">
    <div class="transpond-pop-up  border-radius">
            <div class="transpond-pop-up-top"><h5>转发动态</h5> <i class="icon-all_off"></i></div>
            <div class="transpond-pop-up-1">
                <form id="transpond">
                	<input type="hidden" name="id" value="${aid}">
                	<input type="hidden" name="type" value="${type}">
                    <textarea name="content" id="transpondValue" cols="30" rows="10" placeholder="说说你的看法…"></textarea>
                </form>
            </div>`;
	if (type != 4) {
		str += `<div class="transpond-pop-up-2 border-radius">
               <div class="transpond-pop-up-2-img border-radius"><img class="img-cover" src="${data_cover}" alt=""></div>
                <p class="p-omit">${data_title}</p>
            </div>`;
	}
	str += `<div class="transpond-pop-up-3">
                <div class="add-emoji-button transpond-emoji"><i class="icon-Dgtlex-dgtlexicon-biaoqing"></i></div>
				<div class="icon-more transpond-sub-button"><span>发布</span></div>
				<div class="transpond-more"><span>发布中...</span></div>
            </div>
             <!-- 表情包 -->
            <div class="add-lable addemoji emoji"></div> 
</div>
</div>`;

	if ($('.transpond-pop-up-warp').length == 0) {
		$('body').append(str);
		$('.transpond-pop-up-warp').show();
	} else {
		$('.transpond-pop-up-warp').show();
	}
	$('#transpondValue').focus();
	$('body .transpond-pop-up-warp .transpond-emoji').unbind('click').click('click', function () {
		emojiTab('.transpond-pop-up', '#transpondValue');
	})

	$('body').on('click', '.transpond-pop-up-warp .transpond-sub-button', function () {
		var that = $(this);
		var quote_form_values = $("#transpond").serializeArray();
		var quote_data = '';
		quote_form_values.forEach(function (quote, index) {
			if (quote['name'] == 'content') {
				quote_data = quote['value'];
			}
		});

		if (!$.trim(quote_data)) {
			messageBox('prompt', '内容不能为空');
			return;
		}
		$(this).hide();
		$(this).siblings('.transpond-more').show();
		var url = "/inst/quote";
		$.ajax({
			url: url,
			async: true,
			type: 'post',
			data: $("#transpond").serialize(),
			beforeSend: function () {
				common._loadding();
			},
			complete: function () {
				common._loaddingClose();
			},
			success: function (data) {
				if (data.status == 'success') {
					messageBox('prompt', '转发成功');
					forwardBoxClose();
				} else if (data.status == 'fail') {
					messageBox('prompt', data.message);
					that.show();
					that.siblings('.transpond-more').hide();
				} else if (data.status == 'nologin') {
					messageBox('prompt', '请先登录');
					that.show();
					that.siblings('.transpond-more').hide();
				} else {
					messageBox('prompt', '系统繁忙');
					that.show();
					that.siblings('.transpond-more').hide();
				}
			}
		});
	})


	$('body').on('click', '.transpond-pop-up-warp .transpond-pop-up-top .icon-all_off', function () {
		forwardBoxClose();
	})
}

function forwardBoxClose() {
	$('.transpond-pop-up-warp').remove();
}

//获取表情数据
function getSmile() {
	var url = "/user/getSmile";
	var smile_data = new Array();
	$.ajax({
		url: url,
		async: false,
		type: 'get',
		beforeSend: function () {
			common._loadding();
		},
		complete: function () {
			common._loaddingClose();
		},
		success: function (data) {
			if (data.status == 'success') {
				smile_data = data.data;
			} else {
				smile_data = false;
			}
		},
	});

	return smile_data;
}

/* 轮播点击上报统计 */
function reportClick(obj) {
	var aid = $(obj).attr("aid");
	var carousel_id = $(obj).attr("carousel_id");
	var carousel_type = $(obj).attr("carousel_type");
	var url = `${getApiUrl()}/v1/statistics/carousel/report`;
	jQuery.ajax({
		type: "get",
		url: url,
		data: {
			'id': carousel_id,
			'type': 2,
			'content': `${carousel_type}_${aid}`
		},
		dataType: "json",
		success: function (data) {

		},

	});
}

/* 广告点击上报统计 */
function countAdvHit(obj) {
	var aid = $(obj).attr("aid");
	var url = `${getApiUrl()}/v1/statistics/ad/report`;
	jQuery.ajax({
		type: "get",
		url: url,
		data: {
			'id': aid,
			'type': 2
		},
		dataType: "json",
		success: function (data) {

		},
	});
}

//获取api地址
function getApiUrl() {
	var location_host = window.location.host;
	var url_map = {
		'www.dgtle.com': 'https://opser.api.dgtle.com',
		'release.dgtle.com': 'https://release.api.dgtle.com',
	}

	if (!url_map[location_host]) url_map[location_host] = `https://${location_host}`;

	return url_map[location_host];

}

/*判断用户是否被禁言或者拉黑*/
function getBanInfo(uid) {
	var url = '/message/getBanInfo/' + uid;
	var ban_flag = false;
	$.ajax({
		url: url,
		async: false,
		type: 'get',
		beforeSend: function () {
			common._loadding();
		},
		complete: function () {
			common._loaddingClose();
		},
		success: function (data) {
			switch (data.status) {
				case 'success':
					return ban_flag = true;
				case 'fail':
					messageBox('warning', data.message);
					return ban_flag = false;
				case 'nologin':
					headerFun._showLogin();
					return ban_flag = false;
				default:
					messageBox('warning', '系统繁忙');
					return ban_flag = false;
			}
		}
	});

	return ban_flag;
}

//    视频实例化的方法
function videoCallBack(elem) {
	var videoArr = []
	$(elem).each(function (i, el) {
		videoArr.push(videojs(el))
	})
	$(elem).each(function (i, id) {
		// videojs(id, {}, function () { //自动播放
		// var myPlayer = videojs(id);
		videojs(id).ready(function () {
			var that = this;
			var tempProgress = $('<div class="tempProgressG">' +
				'<div class="tempProgress">' +
				'</div>')
			$(id).append(tempProgress)
			that.on('timeupdate', function () {
				tempProgress = $(id).find('.tempProgress')
				var width = this.currentTime() / this.duration() * 100 + '%'
				tempProgress.css({
					width: width,
					background: '#4CA6E1'
				})
			})
			that.on('play', function () {
				videoArr.filter(x => x != that).forEach(function (video) {
					video.pause()
				})
			})
		});

		// videojs(id).on("click", function () {
		//     if (myPlayer.paused()) {
		//         // $(".vjs-has-started .vjs-big-play-button").show();
		//     } else {
		//         // $(".vjs-has-started .vjs-big-play-button").hide();
		//     }
		// })
		// });
	})

}

//文章页图片处理
function articleImgWith(obj, w1, w2) {
	var oImg = jQuery(obj).find('img');
	jQuery(oImg).addClass("imgDeal"); //在img中插入class,便于dom操作使用naturalHeight属性
	oImg.each(function (key) { //每张图片的key
		var jqThis = jQuery(this);
		jqThis.imagesLoaded(function () {
			var imgNaturalHeight = document.getElementsByClassName('imgDeal')[key].naturalHeight; //每张图片的真实高度
			var imgNaturalWidth = document.getElementsByClassName('imgDeal')[key].naturalWidth; //每张图片的真实高度
			var widthScore = parseInt(imgNaturalWidth);
			var heightScore = parseInt(imgNaturalHeight);
			var score = heightScore / widthScore
			// console.log(score)
			if (score >= 1.2 && score < 1.51) {
				jqThis.css({
					'maxWidth': '700px',
					'maxHeight': 'max-content',
					'height': 'auto',
				})
			} else if (score >= 1.51 && score < 1.91) {
				jqThis.css({
					'maxWidth': '600px',
					'maxHeight': 'max-content',
					'height': 'auto',
				})
			} else if (score >= 1.91) {
				jqThis.css({
					'maxWidth': '530px',
					'maxHeight': 'max-content',
					'height': 'auto',
				})
			}
		});

	})
}
//文章页图片不居中情况处理
function articleImgWithLoaded(jqThis, width, height) {
	var widthScore = parseInt(width);
	var heightScore = parseInt(height);
	var score = heightScore / widthScore
	if (score >= 1.2 && score < 1.51) {
		jqThis.css({
			'maxWidth': '700px',
			'maxHeight': 'max-content',
			'height': 'auto',
		})
	} else if (score >= 1.51 && score < 1.91) {
		jqThis.css({
			'maxWidth': '600px',
			'maxHeight': 'max-content',
			'height': 'auto',
		})
	} else if (score >= 1.91) {
		jqThis.css({
			'maxWidth': '530px',
			'maxHeight': 'max-content',
			'height': 'auto',
		})
	}
}
// //文章页图片不居中情况处理
// function contentImgWith(obj, w1, w2) {
// 	var oImg = jQuery(obj).find('img');
// 	jQuery(oImg).addClass("imgDeal"); //在img中插入class,便于dom操作使用naturalHeight属性

// 	oImg.each(function (key) { //每张图片的key
// 		var jqThis = jQuery(this);
// 		var imgNaturalHeight = document.getElementsByClassName('imgDeal')[key].naturalHeight; //每张图片的真实高度
// 		//   var   imgW = jqThis.attr('width');
// 		var imgW = document.getElementsByClassName('imgDeal')[key].naturalWidth; //每张图片的真实高度
// 		var marNum = 0;
// 		//修改后的      
// 		var widthScore = parseInt(imgW);
// 		var heightScore = parseInt(imgNaturalHeight);
// 		if (heightScore >= 960 && widthScore <= w1) {
// 			jqThis.css({
// 				'width': '500px',
// 				'height': 'auto',
// 				'display': 'block',
// 				'margin': '0 auto',
// 			})
// 		} else if (heightScore >= 960 && widthScore >= w2) {
// 			jqThis.css({
// 				'width': '100%',
// 				'maxWidth': '100%',
// 				'maxHeight': 'max-content',
// 				'height': 'auto',
// 			})
// 		} else if (heightScore >= 960 && (w1 < widthScore < w2)) {
// 			jqThis.css({
// 				'width': '500px',
// 				'height': 'auto',
// 				'margin': '0 auto',
// 				'display': 'block',

// 			})
// 		} else if (heightScore < 960 && widthScore >= w2) {
// 			jqThis.addClass('covered');
// 		} else {
// 			jqThis.wrap('<div class="content_img_box"></div>');
// 			jqThis.parent().css({
// 				'text-align': 'center',
// 				'width': w1 + 'px',
// 				'display': 'inline-block',
// 				'margin': '0 auto'
// 			})

// 		}

// 	})
// }
//获取rul参数值
//name 参数类名
function getUrlParam(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
	var r = window.location.search.substr(1).match(reg);   //匹配目标参数
	if (r != null) return unescape(r[2]);
	return null; //返回参数值
}